package net.shopxx.dto;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.commons.lang.StringUtils;

import net.shopxx.constant.AccountsConstant;

public class TbOrderDTO {

	private static final String STORE_ID_ADULT_1 = "2B男情趣商城";

	private static final String STORE_ID_ADULT_2 = "真丶性情商城";

	/** 订单编号 **/
	private Long orderId;

	/** 买家会员名 **/
	private String buyerUserName;

	/** 买家支付宝账号 **/
	private String buyerAlipay;

	/** 买家应付货款 **/
	private Float tradePayables;

	/** 买家应付邮费 **/
	private Float postage;

	/** 买家支付积分 **/
	private String usedRewardPoints;

	/** 总金额 **/
	private Float totalFee;

	/** 返点积分 **/
	private String rewardPoints;

	/** 买家实际支付金额 **/
	private Float realPaidFee;

	/** 买家实际支付积分 **/
	private String realPaidPoints;

	/** 订单状态 **/
	private String status;

	/** 买家留言 **/
	private String buyersMessage;

	/** 收货人姓名 **/
	private String buyersName;

	/** 收货人地址 **/
	private String buyersAddr;

	/** 运送方式 **/
	private String shippingWay;

	/** 联系电话 **/
	private String contactNumber;

	/** 联系手机 **/
	private String mobileNumber;

	/** 订单创建时间 **/
	private String orderTime;

	/** 付款时间 **/
	private String paidTime;

	/** 宝贝标题 **/
	private String goodsTitle;

	/** 宝贝种类 **/
	private String goodsType;

	/** 物流单号 **/
	private String trackingNumber;

	/** 物流公司 **/
	private String logisticsCompany;

	/** 订单备注 **/
	private String orderComments;

	/** 宝贝总数量 **/
	private Integer goodsTotal;

	/** 店铺Id **/
	private String storeId;

	/** 店铺名称 **/
	private String storeName;

	/** 关闭原因 **/
	private String closeReason;

	/** 卖家服务费 **/
	private Float sellerServiceCharge;

	/** 买家服务费 **/
	private String buyerServiceCharge;

	/** 发票抬头 **/
	private String invoiceTitle;

	/** 是否手机订单 **/
	private String isMobileOrder;

	/** 分阶段订单信息 **/
	private String setpInfo;

	/** 定金排名 **/
	private String depositRanking;

	/** 修改后SKU**/
	private String modifiedSku;

	/** 修改后地址 **/
	private String modifiedAddr;

	/** 异常信息 **/
	private String exceptionInfo;

	/** 天猫卡券抵扣 **/
	private String tianmaoPoints;

	/** 集分宝抵扣 **/
	private String jifenbao;

	/** 是否是O2O交易 **/
	private String isO2O;

	// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-d H:mm");
	SimpleDateFormat sdf = new SimpleDateFormat("M/d/yy H:mm");

	public Long getOrderId() {
		return orderId;
	}

	public void setOrderId(Long orderId) {
		this.orderId = orderId;
	}

	public String getBuyerUserName() {
		return buyerUserName;
	}

	public void setBuyerUserName(String buyerUserName) {
		this.buyerUserName = buyerUserName;
	}

	public String getBuyerAlipay() {
		return buyerAlipay;
	}

	public void setBuyerAlipay(String buyerAlipay) {
		this.buyerAlipay = buyerAlipay;
	}

	public Float getTradePayables() {
		return tradePayables;
	}

	public void setTradePayables(Float tradePayables) {
		this.tradePayables = tradePayables;
	}

	public Float getPostage() {
		return postage;
	}

	public void setPostage(Float postage) {
		this.postage = postage;
	}

	public String getUsedRewardPoints() {
		return usedRewardPoints;
	}

	public void setUsedRewardPoints(String usedRewardPoints) {
		this.usedRewardPoints = usedRewardPoints;
	}

	public Float getTotalFee() {
		return totalFee;
	}

	public void setTotalFee(Float totalFee) {
		this.totalFee = totalFee;
	}

	public String getRewardPoints() {
		return rewardPoints;
	}

	public void setRewardPoints(String rewardPoints) {
		this.rewardPoints = rewardPoints;
	}

	public Float getRealPaidFee() {
		return realPaidFee;
	}

	public void setRealPaidFee(Float realPaidFee) {
		this.realPaidFee = realPaidFee;
	}

	public String getRealPaidPoints() {
		return realPaidPoints;
	}

	public void setRealPaidPoints(String realPaidPoints) {
		this.realPaidPoints = realPaidPoints;
	}

	public Integer getStatus() {
		if (StringUtils.isNotBlank(status) && status.trim().equals(AccountsConstant.ANALYZED_TB_ORDER_STATUS_CLOSED)) {
			return AccountsConstant.TB_ORDER_STATUS_CLOSED;
		} else if (StringUtils.isNotBlank(status) && status.trim().equals(AccountsConstant.ANALYZED_TB_ORDER_STATUS_UNPAID)) {
			return AccountsConstant.TB_ORDER_STATUS_UNPAID;
		} else {
			return AccountsConstant.TB_ORDER_STATUS_NORMAL;
		}
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getBuyersMessage() {
		return buyersMessage;
	}

	public void setBuyersMessage(String buyersMessage) {
		this.buyersMessage = buyersMessage;
	}

	public String getBuyersName() {
		return buyersName;
	}

	public void setBuyersName(String buyersName) {
		this.buyersName = buyersName;
	}

	public String getBuyersAddr() {
		return buyersAddr;
	}

	public void setBuyersAddr(String buyersAddr) {
		this.buyersAddr = buyersAddr;
	}

	public String getShippingWay() {
		return shippingWay;
	}

	public void setShippingWay(String shippingWay) {
		this.shippingWay = shippingWay;
	}

	public String getContactNumber() {
		return contactNumber;
	}

	public void setContactNumber(String contactNumber) {
		this.contactNumber = contactNumber;
	}

	public String getMobileNumber() {
		return mobileNumber.replace("'", "");
	}

	public void setMobileNumber(String mobileNumber) {
		this.mobileNumber = mobileNumber;
	}

	public Date getOrderTime() throws Exception {
		if (StringUtils.isNotBlank(orderTime)) {
			return sdf.parse(orderTime);
		} else {
			return null;
		}
	}

	public void setOrderTime(String orderTime) {
		this.orderTime = orderTime;
	}

	public Date getPaidTime() throws Exception {
		if (StringUtils.isNotBlank(paidTime)) {
			return sdf.parse(paidTime);
		} else {
			return null;
		}
	}

	public void setPaidTime(String paidTime) {
		this.paidTime = paidTime;
	}

	public String getGoodsTitle() {
		return goodsTitle;
	}

	public void setGoodsTitle(String goodsTitle) {
		this.goodsTitle = goodsTitle;
	}

	public String getGoodsType() {
		return goodsType;
	}

	public void setGoodsType(String goodsType) {
		this.goodsType = goodsType;
	}

	public String getTrackingNumber() {
		if (StringUtils.isNotBlank(trackingNumber)) {
			return trackingNumber.replace("No", logisticsCompany);
		} else {
			return null;
		}
	}

	public void setTrackingNumber(String trackingNumber) {
		this.trackingNumber = trackingNumber;
	}

	public String getLogisticsCompany() {
		return logisticsCompany;
	}

	public void setLogisticsCompany(String logisticsCompany) {
		this.logisticsCompany = logisticsCompany;
	}

	public String getOrderComments() {
		return orderComments;
	}

	public void setOrderComments(String orderComments) {
		this.orderComments = orderComments;
	}

	public Integer getGoodsTotal() {
		return goodsTotal;
	}

	public void setGoodsTotal(Integer goodsTotal) {
		this.goodsTotal = goodsTotal;
	}

	public Integer getStoreIdByStoreName() {

		if (StringUtils.isNotBlank(storeName) && storeName.contains(STORE_ID_ADULT_1)) {
			return AccountsConstant.TB_STORE_ID_ADULT_1;
		} else if (StringUtils.isNotBlank(storeName) && storeName.contains(STORE_ID_ADULT_2)) {
			return AccountsConstant.TB_STORE_ID_ADULT_2;
		} else {
			return AccountsConstant.TB_STORE_ID_ERROR;
		}

	}

	public String getStoreId() {
		return storeId;
	}

	public void setStoreId(String storeId) {
		this.storeId = storeId;
	}

	public String getStoreName() {
		return storeName;
	}

	public void setStoreName(String storeName) {
		this.storeName = storeName;
	}

	public String getCloseReason() {
		return closeReason;
	}

	public void setCloseReason(String closeReason) {
		this.closeReason = closeReason;
	}

	public Float getSellerServiceCharge() {
		return sellerServiceCharge;
	}

	public void setSellerServiceCharge(Float sellerServiceCharge) {
		this.sellerServiceCharge = sellerServiceCharge;
	}

	public String getBuyerServiceCharge() {
		return buyerServiceCharge;
	}

	public void setBuyerServiceCharge(String buyerServiceCharge) {
		this.buyerServiceCharge = buyerServiceCharge;
	}

	public Float getFloatBuyerServiceCharge() {
		String bsc = buyerServiceCharge.replace("元", "");
		return Float.valueOf(bsc);
	}

	public String getInvoiceTitle() {
		return invoiceTitle;
	}

	public void setInvoiceTitle(String invoiceTitle) {
		this.invoiceTitle = invoiceTitle;
	}

	public Boolean getIsMobileOrder() {
		if (StringUtils.isNotBlank(isMobileOrder) && isMobileOrder.trim().equals("手机订单")) {
			return true;
		} else {
			return false;
		}
	}

	public void setIsMobileOrder(String isMobileOrder) {
		this.isMobileOrder = isMobileOrder;
	}

	public String getSetpInfo() {
		return setpInfo;
	}

	public void setSetpInfo(String setpInfo) {
		this.setpInfo = setpInfo;
	}

	public String getDepositRanking() {
		return depositRanking;
	}

	public void setDepositRanking(String depositRanking) {
		this.depositRanking = depositRanking;
	}

	public String getModifiedSku() {
		return modifiedSku;
	}

	public void setModifiedSku(String modifiedSku) {
		this.modifiedSku= modifiedSku;
	}

	public String getModifiedAddr() {
		return modifiedAddr;
	}

	public void setModifiedAddr(String modifiedAddr) {
		this.modifiedAddr = modifiedAddr;
	}

	public String getExceptionInfo() {
		return exceptionInfo;
	}

	public void setExceptionInfo(String exceptionInfo) {
		this.exceptionInfo = exceptionInfo;
	}

	public String getTianmaoPoints() {
		return tianmaoPoints;
	}

	public void setTianmaoPoints(String tianmaoPoints) {
		this.tianmaoPoints = tianmaoPoints;
	}

	public String getJifenbao() {
		return jifenbao;
	}

	public void setJifenbao(String jifenbao) {
		this.jifenbao = jifenbao;
	}

	public String getIsO2O() {
		return isO2O;
	}

	public void setIsO2O(String isO2O) {
		this.isO2O = isO2O;
	}

	public Integer getOrderType() {

		if (StringUtils.isNotBlank(orderComments) && orderComments.toUpperCase().contains(AccountsConstant.SHUADAN_SHUIMU_LABLE)) {
			return AccountsConstant.ANALYZED_ORDER_TYPE_SHUA_XU;
		} else if (StringUtils.isNotBlank(orderComments) && orderComments.toUpperCase().contains(AccountsConstant.SHUADAN_QT1366_LABLE)) {
			return AccountsConstant.ANALYZED_ORDER_TYPE_SHUA_QT1366;
		}else if (StringUtils.isNotBlank(orderComments) && orderComments.toUpperCase().contains("CXQM")) {
			return AccountsConstant.ANALYZED_ORDER_TYPE_SHUA;
		} else {
			return AccountsConstant.ANALYZED_ORDER_TYPE_TB;
		}
	}

}
